package top.maochang.hou.dao.impl;


import top.maochang.hou.dao.RoleDao;
import top.maochang.hou.entity.SysMenu;
import top.maochang.hou.entity.SysRole;
import top.maochang.hou.utils.JDBCUtlis;

import java.sql.SQLException;
import java.util.HashMap;
import java.util.List;

public class RoleDaoImpl implements RoleDao {
    @Override
    public List<SysRole> getRoleListrByUserId(String UserId) throws SQLException {
        String sql="select sr.id as id,role_name as roleName,role_code as roleCode,sur.create_time as createTime,sur.update_time as updateTime,sur.is_deleted as isDeleted from  sys_role as sr inner join  sys_user_role sur  on sr.id=sur.role_id where user_id=?";
        return JDBCUtlis.queryForList(SysRole.class,sql,UserId);
    }

    @Override
    public List<SysRole> getRoleList() {
        String sql="select * from  sys_role";
        HashMap hashMap=new HashMap();
        hashMap.put("role_name","roleName");
        hashMap.put("role_code","roleCode");
        hashMap.put("create_time","createTime");
        hashMap.put("update_time","updateTime");
        hashMap.put("is_deleted","isDeleted");
        return JDBCUtlis.queryForListBasicRowProcessor(SysRole.class,sql,hashMap);
    }

}
